<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .font {
        color: red;
      }
      .big {
        font-size: 40px;
      }
      .font-w {
        font-weight: 900;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- <p v-bind:class="show ? 'font' : ''">hello vue</p> -->

      <!-- class允许写成对象的形式 -->
      <!-- 对象里面的key表示类名，value表示变量或者表达式 -->
      <!-- 类名有连字符的，需要加引号 -->
      <!-- class是可以和v-bind:class一起使用 -->
      <!-- <p :class="{ font: show, big: num === 1, 'font-w': weight }" class="abc">
        hello vue
      </p> -->
      <p :class="obj">hello vue</p>

      <button @click="fn">btn</button>

      <!-- 如果给组件添加类名，这个类名会去子组件的根元素上面 -->
      <tb-header class="abc"></tb-header>
    </div>

    <script src="../Vue.js"></script>
    <script>
      Vue.component("TbHeader", {
        template: `
          <header>123</header>
        `,
      });

      new Vue({
        el: "#app",
        data: {
          show: true,
          num: 1,
          weight: true,
        },
        methods: {
          fn() {
            this.weight = false;
          },
        },
        computed: {
          obj() {
            return {
              font: this.show,
              big: this.num === 1,
              "font-w": this.weight,
            };
          },
        },
      });
    </script>
  </body>
</html>
